Enhancement - Support AMDGPU_TARGETS in ROCm CMake builds#793
Enhancement - Support AMDGPU_TARGETS in ROCm CMake builds#793
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for driving ROCm/HIP GPU architecture selection from the AMDGPU_TARGETS environment variable during CMake configuration, to make ROCm micro-benchmark builds work on hosts where hipcc GPU auto-detection is unavailable (e.g., CI without a GPU).
Changes:
- Read
AMDGPU_TARGETSfrom the environment and convert it to a CMake list for use during configuration. - Cache
AMDGPU_TARGETSand (for CMake ≥ 3.21) setCMAKE_HIP_ARCHITECTURESwhen the env var is provided. - Preserve the prior “auto-detection” path when
AMDGPU_TARGETSis not set, and add status logging.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #793 +/- ##
=======================================
Coverage 85.69% 85.69%
=======================================
Files 103 103
Lines 7890 7890
=======================================
Hits 6761 6761
Misses 1129 1129
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Clarify comment: micro-benchmarks are CXX-only via hipcc; CMAKE_HIP_ARCHITECTURES is set only for compatibility with HIP-language projects, not required here. - Normalize whitespace via STRIP + REGEX REPLACE [ \t]+ to avoid empty list elements from leading/trailing or repeated whitespace. - Add FORCE to the cache set so a changed AMDGPU_TARGETS env value overrides any stale cached value on reconfigure. - Replace DEFINED ENV check with non-empty HIP_ARCH_LIST check so an empty or whitespace-only AMDGPU_TARGETS falls back to hipcc auto-detection.
- Broaden the separator regex to accept whitespace, ',', and ';' so values like 'gfx908,gfx90a' or CMake-list 'gfx908;gfx90a' are parsed correctly instead of becoming a single bogus token. - Drop CACHE STRING ... FORCE: use a normal directory-scoped variable for AMDGPU_TARGETS so we do not pollute the global CMake cache or override the variable in nested projects. The env var is re-read on every reconfigure, so this still wins over stale state.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Allow specifying AMD GPU architectures via the AMDGPU_TARGETS environment variable in rocm_common.cmake. This fixes builds on machines without a GPU (e.g., CI) where hipcc auto-detection fails. When unset, the previous auto-detection behavior is preserved.